package com.jrx.anytxn.transaction.service.impl;

import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.transaction.bean.TransferBean;
import com.jrx.anytxn.transaction.service.ITransferMethodStrategy;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

/**
 * @program: anytxn-cf-transaction
 * @description: 当期金额转列法转列策略
 * @author: xiaoyu.jing
 * @date: 2019-11-15 12:50
 **/
@Order(3)
@Service
public class CurrentAmountTransferMethodStrategy implements ITransferMethodStrategy {

    /**
     * 当期金额转列法账户外转列处理 会计状态升级，转非应计，五级分类升级
     *
     * @param transferBean
     * @return
     * @throws TxnException
     */
    @Override
    public TransferBean transferOut(TransferBean transferBean) {
        int delqDays = transferBean.getDelqDays();
        int delqMaxDays = transferBean.getMaxDelqDays();
        return transferBean.setAccountingDays(delqDays).setNonAccrualDays(delqDays).setClassifyDays(delqMaxDays);
    }

    /**
     * 当期金额转列法账户内转列处理 会计状态降级，转应计，五级分类降级
     *
     * @param transferBean
     * @return
     * @throws TxnException
     */
    @Override
    public TransferBean transferIn(TransferBean transferBean) {
        int delqDays = transferBean.getDelqDays();
        int delqMaxDays = transferBean.getMaxDelqDays();
        return transferBean.setAccountingDays(delqDays).setNonAccrualDays(delqDays).setClassifyDays(delqMaxDays);
    }
}
